let img = document.querySelectorAll(".swiper>img");
let previous = document.querySelector(".swiper>.previous");
let next = document.querySelector(".swiper>.next");
let swiperBtn = document.querySelectorAll(".swiperBtn>ul>li");
let lastIndex = 0;

  next.addEventListener("click",function(){
    swiperBtn[lastIndex].classList.remove("bgColor");
    img[lastIndex].classList.remove("active");
    ++lastIndex;
<<<<<<< HEAD
    if(lastIndex>=img.length){
=======
    if(lastIndex>=3){
>>>>>>> origin/lhq
      lastIndex=0;
    }
    swiperBtn[lastIndex].classList.add("bgColor");
    img[lastIndex].classList.add("active");
  })

  previous.addEventListener("click",function(){
    swiperBtn[lastIndex].classList.remove("bgColor");
    img[lastIndex].classList.remove("active");
    --lastIndex;
<<<<<<< HEAD
    //到达第一张，再次点击则跳回最后一张
    if(lastIndex<0){
      lastIndex=img.length-1;
=======
    if(lastIndex<0){
      lastIndex=2;
>>>>>>> origin/lhq
    }
    swiperBtn[lastIndex].classList.add("bgColor");
    img[lastIndex].classList.add("active");
  })

  swiperBtn.forEach(function(item,index){
    item.addEventListener("click",function(){
      swiperBtn[lastIndex].classList.remove("bgColor");
      item.classList.add("bgColor");
      img[lastIndex].classList.remove("active");
      img[index].classList.add("active");
      lastIndex = index;
    })
  })


